import request from '@/utils/request'
import { pramsToQuery } from '@/utils/index'

// 获取审批列表
export function getApprovalList(data) {
  return request({
    url: `/approve/approve/approveInst?${pramsToQuery(data)}`,
    method: 'get',
    data
  })
}
// 获取流程定义的list
export function getBPMDefineList(data) {
  return request({
    url: '/deploy/process',
    method: 'post',
    data
  })
}
// 获取流程信息的详情
export function getBPMXMLInfo(params) {
  return request({
    url: '/deploy/bpmn',
    params
  })
}
// 发布流程
export function publishBpmFile(data) {
  return request({
    url: '/deploy/file',
    method: 'post',
    data
  })
}
// 发布流程json
export function publishBpmJSON(data) {
  return request({
    url: '/deploy/json',
    method: 'post',
    data
  })
}
// 获取流程json
export function getBpmJSON(processDefinitionKey) {
  return request({
    url: `/deploy/definition/${processDefinitionKey}`
  })
}
// 获取审批管理
export function getApprovalAdminList(data) {
  return request({
    url: `/approve/approve/approveGroupDefinition?${pramsToQuery(data)}`,
    method: 'get',
    data
  })
}
// 获取审批组
export function getFlowApprove(data) {
  return request({
    url: `/approve/approve/approveGroup`,
    method: 'get',
    data
  })
}
// 获取审批数据
export function getFlowInfo(data) {
  return request({
    url: `/approve/approve/approveDefinition/${data.id}?${pramsToQuery(data)}`,
    method: 'get',
    data
  })
}
// 添加审批数据
export function addFlowInfo(data) {
  return request({
    url: `/approve/approve/approveDefinition`,
    method: 'post',
    data
  })
}
// 审批状态修改（停用、启用）
export function stateFlowInfo(data) {
  return request({
    url: `/approve/approve/approveDefinition/isValid?${pramsToQuery(data)}`,
    method: 'get',
    data
  })
}
// 获取filekey
export function getFileKey(data) {
  return request({
    url: `/approve/approve/seq`,
    method: 'get',
    data
  })
}

export function getUserList(data) {
  return request({
    url: '/user/list',
    method: 'post',
    data
  })
}
// 获取流程历史
export function getHistoryList(data) {
  return request({
    url: '/history/task',
    method: 'post',
    data
  })
}
// 添加自定义配置
export function addCusromConfig(data) {
  return request({
    url: '/field/add',
    method: 'post',
    data
  })
}
// 获取自定义配置列表
export function getCusromConfigList(data) {
  return request({
    url: '/field/list',
    method: 'post',
    data
  })
}
// 编辑自定义配置
export function editCusromConfig(data) {
  return request({
    url: '/field/edit',
    method: 'post',
    data
  })
}
// 删除自定义配置
export function delCusromConfig(data) {
  return request({
    url: `/field/del/${data}`,
    method: 'delete'
  })
}
// 获取审批登记用户列表list
export function getProcessList(data) {
  return request({
    url: '/process/list',
    method: 'get'
  })
}

// 创建审批登记
export function creatProcess(data) {
  return request({
    url: '/process/add',
    method: 'post',
    data
  })
}
// 编辑审批登记
export function editProcess(data) {
  return request({
    url: '/process/edit',
    method: 'post',
    data
  })
}
// 删除审批登记
export function deleteProcess(data) {
  return request({
    url: `/process/del/${data}`,
    method: 'delete'
  })
}
//  获取审批登记用户
export function getUserProcessList(data) {
  return request({
    url: `/user/process/${data}`,
    method: 'get'
  })
}
//  获取审批登记用户
export function userList(data) {
  return request({
    url: `/user/list`,
    method: 'post',
    data
  })
}
//  添加编辑审批登记用户
export function addUserProcess(id, data, email) {
  return request({
    url: `/user/process/${id}?createdBy=${email}`,
    method: 'post',
    data
  })
}
// 删除审批登记用户
export function deldUserProcess(id, data) {
  return request({
    url: `/user/process/del/${id}`,
    method: 'delete',
    data
  })
}
// 获取业务线数据
export function getBusinessLines() {
  return request({
    url: ''
  })
}
/**
 * 获取业务线下拉
 */
export function getBusinessLinesOption() {
  return request({
    url: '/business/system/options',
    method: 'get'
  })
}

// 获取当前流程实例的任务节点信息
export function getProcessTasks(id, data) {
  return request({
    url: `/process/tasks/${id}`,
    method: 'get',
    data
  })
}
//  减签
export function taskRemoveSign(params, data) {
  return request({
    url: `/task/remove/sign/${params.businessKey}/${params.assignee}`,
    method: 'post',
    data
  })
}
